//var username=localStorage.getItem("username");
var token=localStorage.getItem("token");
//var userid=localStorage.getItem("userid");
$(function(){
	//初始化时间控件，起始时间小于结束日期
	$("#startTime").datetimepicker({
		lang:'ch',
		timepicker:false,
		format:'Y/m/d',
		formatDate:'Y/m/d',
		onShow:function(){
			this.setOptions({
				maxDate:$("#endTime").val()?$("#endTime").val():0
			});
		}
	});
	$("#endTime").datetimepicker({
		lang:'ch',
		timepicker:false,
		format:'Y/m/d',
		formatDate:'Y/m/d',
		maxDate:0,
		onShow:function(){
			this.setOptions({
				minDate:$("#startTime").val()?$("#startTime").val():false
			});
		}
	});
	/**
	 * 截取参数
	 */
	var url = tl_config.his_url;
	var start =url.indexOf('?')+1;
	var params = url.substring(start);
	var parr = [];
	var paramMap = {
	};
	parr = params.split('&');
	for(var i in parr){
		var key=parr[i].substring(parr[i].indexOf('='),0);
		paramMap[key]=parr[i].substring(parr[i].indexOf('=')+1);
	}
	var id = paramMap['id'];
//	var curPage=paramMap['curPage'];
	console.log(id);
//	console.log("curPage:"+curPage);
//	id='cfbc0d15fc4840c3ac7d73716f063cd2';
	
	gridObj = $.fn.bsgrid.init('t_tabYeb', {
		ajaxType : 'get',
		url : server_url+'rest/logList.do?staffId='+id+'&token='+token+'&ran='+Math.random(),
		autoLoad : true,
		pageSizeSelect : true,
		stripeRows : true,
		pageSize : 10,
		displayBlankRows : false,
		isProcessLockScreen : true,
		rowSelectedColor : false
	});
	
	$("#logQuery").click(function(){
//		console.log('startTime:'+$("#startTime").val());
//		console.log('endTime:'+$("#endTime").val());
		var serParam=$("#Lform").serialize();
		if ($('#post_name').val() == '') {
			gridObj.search('');
		} else {
			gridObj.search(serParam);
		}
		
	});
	
	$("#logBack").click(function(){
		var url='staffList.do?ran='+Math.random();
		tl_config.loadToWorkArea(url);
	});
	
});


